package com.bo.Interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;





public class UserAccessInterceptor extends HandlerInterceptorAdapter{
	
	
	public boolean preHandle(HttpServletRequest request,HttpServletResponse response,
			                                               Object handler) throws Exception {
			
	
		
		Object obj=request.getSession().getAttribute("isLogin");
		
		boolean isLogin = obj!=null ? (Boolean)obj : false;

		if(isLogin){
			
			return true;
		
		}else{
			
		    String path = request.getContextPath();
			response.sendRedirect("/"+path);
			
			return false;
		}
	}

}
